<?php
/* Definicion de constantes
--------------------------------------------- */
define('INC', ABSPATH . 'includes/' );
define('LANGPATH', ABSPATH . 'content/languages/' );

require INC . 'db.php';

$db = new db( DBHOST, DBUSER, DBPASS, DBNAME );

/* Opciones Globales
--------------------------------------------- */
// Autocarga de opciones
$db->query( "SELECT * FROM {$db->options} WHERE autoload='1'" );
$results = $db->get_results();

foreach( $results as $option ){
	$temp = $option->option_name;
	if( !@unserialize($option->option_value) )
		$$temp = $option->option_value;
	else
		$$temp = unserialize($option->option_value);
	unset($temp);
}
unset($results);

/* Carga de Archivos
--------------------------------------------- */
require INC . 'options.php';
require INC . 'plugin.php';
require INC . 'rewrite.php';
//require INC . 'form.php';

/* Carga de Idioma
--------------------------------------------- */
require INC . 'locale/gettext.php';
require INC . 'locale/streams.php';

if( file_exists( LANGPATH . LANG . '.mo' ) ) {
	$gettext_tables = new gettext_reader( new CachedFileReader(LANGPATH . LANG . '.mo') );
	$gettext_tables->load_tables();
}

function __($texto) {
	global $gettext_tables;

	if ( is_null($gettext_tables) ) return $texto;
	
	return $gettext_tables->translate($texto);
}
function _e($source){
	echo __($source);
}

/* Generar URLs dinamicas
--------------------------------------------- */
if( defined('ADMINPATH') ){
	$rewrite = new rewrite();
	$rewrite->make();
}



//var_dump( option::set('siteurl', 'http://localhost/tech', true) );
/*
var_dump( options::get('sitename2') );

require INC . 'form/input.php';
require INC . 'form/radius.php';

$field = new input();
echo $field->getHTML();

$field = new radius();
echo $field->getHTML();
*/
?>